
package cn.edu.scau.cmi.hombio.service;

import cn.edu.scau.cmi.hombio.domain.Medicine;
import cn.edu.scau.cmi.hombio.domain.MedicinePrice;
import cn.edu.scau.cmi.hombio.domain.MedicineSupplier;
import cn.edu.scau.cmi.hombio.domain.Supplier;

import java.util.List;
import java.util.Set;

import org.junit.Test;

import org.junit.runner.RunWith;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.beans.factory.support.DefaultListableBeanFactory;

import org.springframework.context.ApplicationContext;

import org.springframework.mock.web.MockHttpServletRequest;

import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestExecutionListeners;

import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
import org.springframework.test.context.support.DirtiesContextTestExecutionListener;

import org.springframework.test.context.transaction.TransactionalTestExecutionListener;

import org.springframework.transaction.annotation.Transactional;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.RequestScope;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.context.request.SessionScope;

/**
 * Class to run the service as a JUnit test. Each operation in the service is a separate test.
 *
 */

@RunWith(SpringJUnit4ClassRunner.class)
@TestExecutionListeners({
		DependencyInjectionTestExecutionListener.class,
		DirtiesContextTestExecutionListener.class,
		TransactionalTestExecutionListener.class })
@ContextConfiguration(locations = {
		"file:./resources/pigRs-security-context.xml",
		"file:./resources/pigRs-service-context.xml",
		"file:./resources/pigRs-dao-context.xml",
		"file:./resources/pigRs-web-context.xml" })
@Transactional
public class MedicineSupplierServiceTest {

	/**
	 * The Spring application context.
	 *
	 */
	@SuppressWarnings("unused")
	private ApplicationContext context;

	/**
	 * The service being tested, injected by Spring.
	 *
	 */
	@Autowired
	protected MedicineSupplierService service;

	/**
	 * Instantiates a new MedicineSupplierServiceTest.
	 *
	 */
	public MedicineSupplierServiceTest() {
		setupRequestContext();
	}

	/**
	 * Operation Unit Test
	* Save an existing MedicineSupplier entity
	* 
	 */
	@Test
	public void saveMedicineSupplier() {
		// TODO: JUnit - Populate test inputs for operation: saveMedicineSupplier 
		MedicineSupplier medicinesupplier = new cn.edu.scau.cmi.hombio.domain.MedicineSupplier();
		service.saveMedicineSupplier(medicinesupplier);
	}

	/**
	 * Operation Unit Test
	* Return all MedicineSupplier entity
	* 
	 */
	@Test
	public void findAllMedicineSuppliers() {
		// TODO: JUnit - Populate test inputs for operation: findAllMedicineSuppliers 
		Integer startResult = 0;
		Integer maxRows = 0;
		List<MedicineSupplier> response = null;
		response = service.findAllMedicineSuppliers(startResult, maxRows);
		// TODO: JUnit - Add assertions to test outputs of operation: findAllMedicineSuppliers
	}

	/**
	 * Operation Unit Test
	* Delete an existing Medicine entity
	* 
	 */
	@Test
	public void deleteMedicineSupplierMedicine() {
		// TODO: JUnit - Populate test inputs for operation: deleteMedicineSupplierMedicine 
		Integer medicinesupplier_id = 0;
		Integer related_medicine_id = 0;
		MedicineSupplier response = null;
		response = service.deleteMedicineSupplierMedicine(medicinesupplier_id, related_medicine_id);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteMedicineSupplierMedicine
	}

	/**
	 * Operation Unit Test
	* Delete an existing Supplier entity
	* 
	 */
	@Test
	public void deleteMedicineSupplierSupplier() {
		// TODO: JUnit - Populate test inputs for operation: deleteMedicineSupplierSupplier 
		Integer medicinesupplier_id_1 = 0;
		Integer related_supplier_id = 0;
		MedicineSupplier response = null;
		response = service.deleteMedicineSupplierSupplier(medicinesupplier_id_1, related_supplier_id);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteMedicineSupplierSupplier
	}

	/**
	 * Operation Unit Test
	* Delete an existing MedicinePrice entity
	* 
	 */
	@Test
	public void deleteMedicineSupplierMedicinePrices() {
		// TODO: JUnit - Populate test inputs for operation: deleteMedicineSupplierMedicinePrices 
		Integer medicinesupplier_id_2 = 0;
		Integer related_medicineprices_id = 0;
		MedicineSupplier response = null;
		response = service.deleteMedicineSupplierMedicinePrices(medicinesupplier_id_2, related_medicineprices_id);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteMedicineSupplierMedicinePrices
	}

	/**
	 * Operation Unit Test
	 */
	@Test
	public void findMedicineSupplierByPrimaryKey() {
		// TODO: JUnit - Populate test inputs for operation: findMedicineSupplierByPrimaryKey 
		Integer id = 0;
		MedicineSupplier response = null;
		response = service.findMedicineSupplierByPrimaryKey(id);
		// TODO: JUnit - Add assertions to test outputs of operation: findMedicineSupplierByPrimaryKey
	}

	/**
	 * Operation Unit Test
	* Save an existing MedicinePrice entity
	* 
	 */
	@Test
	public void saveMedicineSupplierMedicinePrices() {
		// TODO: JUnit - Populate test inputs for operation: saveMedicineSupplierMedicinePrices 
		Integer id_1 = 0;
		MedicinePrice related_medicineprices = new cn.edu.scau.cmi.hombio.domain.MedicinePrice();
		MedicineSupplier response = null;
		response = service.saveMedicineSupplierMedicinePrices(id_1, related_medicineprices);
		// TODO: JUnit - Add assertions to test outputs of operation: saveMedicineSupplierMedicinePrices
	}

	/**
	 * Operation Unit Test
	* Save an existing Medicine entity
	* 
	 */
	@Test
	public void saveMedicineSupplierMedicine() {
		// TODO: JUnit - Populate test inputs for operation: saveMedicineSupplierMedicine 
		Integer id_2 = 0;
		Medicine related_medicine = new cn.edu.scau.cmi.hombio.domain.Medicine();
		MedicineSupplier response = null;
		response = service.saveMedicineSupplierMedicine(id_2, related_medicine);
		// TODO: JUnit - Add assertions to test outputs of operation: saveMedicineSupplierMedicine
	}

	/**
	 * Operation Unit Test
	* Return a count of all MedicineSupplier entity
	* 
	 */
	@Test
	public void countMedicineSuppliers() {
		Integer response = null;
		response = service.countMedicineSuppliers();
		// TODO: JUnit - Add assertions to test outputs of operation: countMedicineSuppliers
	}

	/**
	 * Operation Unit Test
	* Delete an existing MedicineSupplier entity
	* 
	 */
	@Test
	public void deleteMedicineSupplier() {
		// TODO: JUnit - Populate test inputs for operation: deleteMedicineSupplier 
		MedicineSupplier medicinesupplier_1 = new cn.edu.scau.cmi.hombio.domain.MedicineSupplier();
		service.deleteMedicineSupplier(medicinesupplier_1);
	}

	/**
	 * Operation Unit Test
	* Load an existing MedicineSupplier entity
	* 
	 */
	@Test
	public void loadMedicineSuppliers() {
		Set<MedicineSupplier> response = null;
		response = service.loadMedicineSuppliers();
		// TODO: JUnit - Add assertions to test outputs of operation: loadMedicineSuppliers
	}

	/**
	 * Operation Unit Test
	* Save an existing Supplier entity
	* 
	 */
	@Test
	public void saveMedicineSupplierSupplier() {
		// TODO: JUnit - Populate test inputs for operation: saveMedicineSupplierSupplier 
		Integer id_3 = 0;
		Supplier related_supplier = new cn.edu.scau.cmi.hombio.domain.Supplier();
		MedicineSupplier response = null;
		response = service.saveMedicineSupplierSupplier(id_3, related_supplier);
		// TODO: JUnit - Add assertions to test outputs of operation: saveMedicineSupplierSupplier
	}

	/**
	 * Autowired to set the Spring application context.
	 *
	 */
	@Autowired
	public void setContext(ApplicationContext context) {
		this.context = context;
		((DefaultListableBeanFactory) context.getAutowireCapableBeanFactory()).registerScope("session", new SessionScope());
		((DefaultListableBeanFactory) context.getAutowireCapableBeanFactory()).registerScope("request", new RequestScope());
	}

	/**
	 * Sets Up the Request context
	 *
	 */
	private void setupRequestContext() {
		MockHttpServletRequest request = new MockHttpServletRequest();
		ServletRequestAttributes attributes = new ServletRequestAttributes(request);
		RequestContextHolder.setRequestAttributes(attributes);
	}
}
